package com.spzx.product.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.spzx.common.core.web.domain.BaseEntity;

import java.io.Serial;
import java.util.List;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.*;
import lombok.experimental.SuperBuilder;

/**
 * <p>
 * 商品规格
 * </p>
 *
 * @author Haoran Sun
 * @since 2024-07-15
 */
@Getter
@Setter
@TableName("product_spec")
@Schema(description = "商品规格")
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
public class ProductSpec extends BaseEntity {
    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "分类id")
    @TableField("category_id")
    @NotNull(message = "分类id不能为空")
    private Long categoryId;

    @Schema(description = "规格名称")
    @TableField("spec_name")
    @NotBlank(message = "规格名称不能为空")
    @Size(min = 1, max = 64, message = "规格名称长度必须在1-64之间")
    private String specName;

    @Schema(description = "规格值：\"[{\"key\":\"颜色\",\"valueList\":[\"蓝\",\"白\",\"红\"]]\"")
    @TableField("spec_value")
    @NotBlank(message = "规格值不能为空")
    @Size(min = 1, max = 500, message = "规格值长度必须在1-500之间")
    private String specValue;

    @Schema(description = "分类名称")
    @TableField(exist = false)
    private String categoryName;

    @Schema(description = "分类id列表")
    @TableField(exist = false)
    private List<Long> categoryIdList;

}
